#include "handtopbtn.h"
#include "ui_handtopbtn.h"

HandTopBtn::HandTopBtn(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::HandTopBtn)
{
    ui->setupUi(this);
    m_index = 0;
    ui->widget->installEventFilter(this);
}

HandTopBtn::~HandTopBtn()
{
    delete ui;
}

void HandTopBtn::setPicName(QString picStyle, QString name)
{
     ui->labelPic->setStyleSheet(picStyle);
     ui->labelName->setText(name);
     m_TextName = name;
}

void HandTopBtn::setIndex(int index)
{
    m_index = index;
}

int HandTopBtn::getIndex()
{
    return m_index;
}

void HandTopBtn::setNormalStyle()
{
    ui->labelBttomLine->setStyleSheet("border-image: url();");
}

void HandTopBtn::setClickedStyle()
{
    ui->labelBttomLine->setStyleSheet("border-image: url(:/new/prefix1/Resource/AutoLine.png);");
}

bool HandTopBtn::eventFilter(QObject *watched, QEvent *event)
{
    if(event->type() == QEvent::MouseButtonPress)
    {
       emit sigClicked(m_TextName);
       setClickedStyle();
    }
    return false;
}
